// transformer.ts
import Konva from 'konva';

export class TransformerManager {
    private transformer: Konva.Transformer;

    constructor(layer: Konva.Layer) {
        this.transformer = new Konva.Transformer({
            resizeEnabled: true,
            rotateEnabled: true,
            keepRatio: true,
        });
        layer.add(this.transformer);
    }

    // 绑定 Transformer 到多个图形
    bindToShapes(selectedShapes: Konva.Node[]) {
        this.transformer.nodes(selectedShapes);
    }

    // 清除 Transformer 绑定
    clear() {
        this.transformer.nodes([]);
    }
}
